package com.online.olsrootserver.service.impl;

import com.online.olsrootserver.entity.Customer;
import com.online.olsrootserver.master.CustomerMapper;
import com.online.olsrootserver.service.CustomerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by littleheng on 2018/5/8
 */
@Service
public class CustomerServiceImpl implements CustomerService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public int addCustomer(Customer customer) {
        int result = 0;
        if (customer == null) {
            this.logger.info("addCustomer：参数为空");
            return result;
        }
        result = this.customerMapper.insertCustomerInfo(customer);
        return result;
    }

    @Override
    public int checkCustomer(String openId) {
        int result = -1;
        if ("".equals(openId)) {
            this.logger.info("checkCustomer：参数为空");
            return result;
        }
        result = this.customerMapper.selectCustomerByOpenId(openId);
        return result;
    }

    @Override
    public int modifySubscribeStatus(String openId, String status) {
        int result = 0;
        if ("".equals(openId) || "".equals(status)) {
            this.logger.info("modifySubscribeStatus：参数为空");
            return result;
        }
        result = this.customerMapper.updateSubscribeStatus(openId, status);
        return result;
    }
}